public class StateMachine
{
    EntityState state;

    // ========================================================================

    public void Init(EntityState initState)
    {
        state = initState;
        state.Enter();
    }

    public void Transition(EntityState newState)
    {
        state.Exit();
        state = newState;
        state.Enter();
    }

    public bool TryTransition(EntityState newState)
    {
        if (!newState.Check()) return false;
        Transition(newState);
        return true;
    }

    public void Process() => state.Process();

    public void LateProcess() => state.LateProcess();
}